﻿namespace c__study_2_21
{
    class Person
    {
        public void Eat(Food f)
        {
            Console.WriteLine("{0}吃了{1},食物的热量为{2}大卡",name,f.name,f.kaluli);
        }
        public void Walk()
        {
            Console.WriteLine("{0}正在散步", name);
        }
        public void Speak(string say)
        {
            Console.WriteLine("{0}说{1}",name,say);
        }
        public string name;
    }
    class Food
    {
       public int kaluli;
        public string name;
    }
    class Student
    {
        public int age;
        public Student deskmate;
        public Student()
        {
            ;
        }
        public Student(int age)
        {
            this.age = age;
        }
        public Student(int age,Student deskmate):this(age)
        {
            this.deskmate=deskmate;
        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {
            #region 练习题
           // Student s = new Student();
           //s.deskmate = new Student();
           // s.deskmate.age = 10;
           // Console.WriteLine(s.deskmate.age);
           // Student s2 = s.deskmate;
           // s2.age = 20;
           // Console.WriteLine(s2.age);
           // Console.WriteLine(s.deskmate.age);
            #endregion
            #region
            //Person p = new Person();
            //p.name = "小明";
            //Food f = new Food();
            //f.kaluli = 500;
            //f.name = "汉堡";
            //p.Eat(f);
            #endregion
            //构造函数，重载和this
            Student s2 = new Student();
            Student s=new Student(18,s2);
            Console.WriteLine(s.age);
        }
    }
}
